package com.yootk.po;

import jakarta.persistence.*;

import java.util.List;

@Entity
public class Dept {
    @Id
    private Long deptno ;
    private String dname ;
    private String loc ;
    @OneToMany(mappedBy = "dept",cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    private List<Emp> emps ;

    public Dept() {
    }

    public Dept(Long deptno, String dname, String loc) {
        this.deptno = deptno;
        this.dname = dname;
        this.loc = loc;
    }

    public Long getDeptno() {
        return deptno;
    }

    public void setDeptno(Long deptno) {
        this.deptno = deptno;
    }

    public String getDname() {
        return dname;
    }

    public void setDname(String dname) {
        this.dname = dname;
    }

    public String getLoc() {
        return loc;
    }

    public void setLoc(String loc) {
        this.loc = loc;
    }

    public List<Emp> getEmps() {
        return emps;
    }

    public void setEmps(List<Emp> emps) {
        this.emps = emps;
    }

    @Override
    public String toString() {
        return "【部门信息】" +
                "编号=" + deptno +
                ", 名称='" + dname + '\'' +
                ", 位置='" + loc  ;
    }
}
